﻿<%@ Page Language="C#" MasterPageFile="~/SiteLayout.Master" AutoEventWireup="true" CodeBehind="AddTreeProducts.aspx.cs" Inherits="ForestryEnterprise.AddTreeProducts" %>

<asp:Content ID="Content2" ContentPlaceHolderID="context" runat="server">
    <h2>Add Tree Products</h2>
    <hr />
    <label>Pick tree:</label>
    <asp:DropDownList ID="trees" runat="server" 
        onselectedindexchanged="trees_SelectedIndexChanged" AutoPostBack="true"/>
    <br />
    <label>Product name:</label>
    <asp:TextBox ID="prodName" runat="server" />
    <br />
    <label>Product cost:</label>
    <asp:TextBox ID="prodCost" runat="server" />
    <br />
    <label>Product description:</label>
    <asp:TextBox ID="prodDesc" runat="server" />
    <br />
    <asp:Button ID="addProd" Text="Add new" runat="server" 
        onclick="addProd_Click" />
    <hr />
    <asp:GridView ID="productsDataView" AutoGenerateColumns="False" 
        DataSourceID="productsData" DataKeyName="prod_id" runat="server" 
        EnableModelValidation="True" 
        onselectedindexchanged="productsDataView_SelectedIndexChanged" Width="100%">
        <AlternatingRowStyle BackColor="#F0F0F0"/>
        <Columns>
            <asp:CommandField ShowSelectButton="True" HeaderText="Update" SelectText="update" HeaderStyle-ForeColor="White" HeaderStyle-BackColor="#A3A3A3"/>
            <asp:BoundField DataField="prod_id" HeaderText="Product ID" InsertVisible="false" ReadOnly="true" HeaderStyle-ForeColor="White" HeaderStyle-BackColor="#A3A3A3"/>
            <asp:BoundField DataField="prod_name" HeaderText="Name" InsertVisible="false" ReadOnly="true" HeaderStyle-ForeColor="White" HeaderStyle-BackColor="#A3A3A3"/>
            <asp:BoundField DataField="prod_cost" HeaderText="Price" InsertVisible="false" ReadOnly="true" HeaderStyle-ForeColor="White" HeaderStyle-BackColor="#A3A3A3"/>
            <asp:BoundField DataField="prod_desc" HeaderText="Description" InsertVisible="false" ReadOnly="true" HeaderStyle-ForeColor="White" HeaderStyle-BackColor="#A3A3A3"/>
        </Columns>
    </asp:GridView>
    <asp:AccessDataSource ID="productsData" DataFile="~/App_Data/ForestryEnterprise.mdb" runat="server" />
    <br />
    <div id="updateItem" runat="server" visible="false">
        <hr />
        <asp:TextBox ID="updateName" runat="server" />
        <asp:TextBox ID="updateCost" runat="server" />
        <asp:TextBox ID="updateDesc" runat="server" />
        <asp:Button ID="update" Text="Update" runat="server" onclick="update_Click" />
        <asp:Button ID="cancel" Text="Cancel" runat="server" onclick="cancel_Click" />
        <asp:RegularExpressionValidator ID="regUpdateCost" ControlToValidate="updateCost" ValidationExpression="[0-9]*\.?[0-9]*" ErrorMessage="Cost must be number (float xx.yy)" runat="server" ForeColor="Red"/>
    </div>
</asp:Content>